﻿using Microsoft.SharePoint.Administration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SPDocumentor.FarmServices
{
    public static class Helper
    {
        public static int? GetPortNumber(SPWebApplication application)
        {
            int? result = null;
            SPIisSettings setting = null;
            if (application.IisSettings.TryGetValue(SPUrlZone.Default, out setting))
            {
                if (null != setting)
                {
                    var serverBindings = setting.ServerBindings;
                    if (0 < serverBindings.Count)
                    {
                        SPServerBinding serverBinding = serverBindings[0];
                        result = serverBinding.Port;
                    }
                }
            }
            return result;
        }
    }
}
